package com.mcr.graduateprogram.controller;


import com.mcr.graduateprogram.bean.Others;
import com.mcr.graduateprogram.common.R;
import com.mcr.graduateprogram.service.IOthersService;
import com.mcr.graduateprogram.service.IPhotoUpload;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author graduateprogram
 * @since 2023-02-25
 */
@Api(tags = "进行一些杂项设置")
@CrossOrigin
@RestController
@RequestMapping("/graduateprogram/others")
public class OthersController {
    @Autowired
    private IOthersService iOthersService;
    @Autowired
    private IPhotoUpload photoUpload;
    @Value("${qiniu.others}")
    private String others;
    @ApiOperation(value = "上传轮播图1，2，3")
    @PostMapping("uploadSlideshow")
    public R uploadSlideshow(@RequestPart("slideshow")MultipartFile slideshow){
        return R.success(photoUpload.photoUpload(slideshow,others));
    }
    @ApiOperation(value = "获取轮播图1，2，3和其他所有杂项设置")
    @GetMapping("getSlideShow")
    public R getSlideShow(){
        return R.success(iOthersService.getOne(null));
    }
    @ApiOperation(value = "修改杂项配置")
    @PostMapping("updateOthers")
    public R updateOthers(@RequestBody Others others){
        System.out.println(others.toString());
        return R.success(iOthersService.updateOthers(others));
    }
}
